define('components/checkboxes/checkboxes.tpl',['hdbr'], function(Handlebars) {
			return Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "        <li class=\""
    + alias4(((helper = (helper = helpers.className || (depth0 != null ? depth0.className : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"className","hash":{},"data":data}) : helper)))
    + "\">\r\n        \r\n            <div "
    + ((stack1 = (helpers.ifInDisabledValue || (depth0 && depth0.ifInDisabledValue) || alias2).call(alias1,(depth0 != null ? depth0.value : depth0),{"name":"ifInDisabledValue","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "\r\n                "
    + ((stack1 = (helpers.ifInDefaultValue || (depth0 && depth0.ifInDefaultValue) || alias2).call(alias1,(depth0 != null ? depth0.value : depth0),{"name":"ifInDefaultValue","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + " >\r\n                <input type=\"checkbox\" \r\n                    "
    + ((stack1 = (helpers.ifInDisabledValue || (depth0 && depth0.ifInDisabledValue) || alias2).call(alias1,(depth0 != null ? depth0.value : depth0),{"name":"ifInDisabledValue","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + " "
    + ((stack1 = (helpers.ifInDefaultValue || (depth0 && depth0.ifInDefaultValue) || alias2).call(alias1,(depth0 != null ? depth0.value : depth0),{"name":"ifInDefaultValue","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + " \r\n                    value=\""
    + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
    + "\" >\r\n                <ins></ins>\r\n            </div>\r\n            <label >"
    + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
    + "</label>\r\n        </li>\r\n";
},"2":function(container,depth0,helpers,partials,data) {
    return "disabled=disabled class=\"disabled\"";
},"4":function(container,depth0,helpers,partials,data) {
    return "class=\"checked\"";
},"6":function(container,depth0,helpers,partials,data) {
    return "disabled=disabled";
},"8":function(container,depth0,helpers,partials,data) {
    return "checked=checked";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"sn-checkboxes "
    + container.escapeExpression(((helper = (helper = helpers.className || (depth0 != null ? depth0.className : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"className","hash":{},"data":data}) : helper)))
    + "\">\r\n    <ul class=\"chk-list\">\r\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.items : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </ul>\r\n</div>";
},"useData":true})
		});

define('lib/requirejs/css.min!components/checkboxes/checkboxes',[],function(){});
define('checkboxes',[
    'jquery',
    'eventTarget',
    'components/checkboxes/checkboxes.tpl',
    'hdbr',
    'lib/requirejs/css.min!components/checkboxes/checkboxes.css'
],function ($, eventTarget, template,hdbr){
    var VERSION = '1.1.4';
    var num = 0;
    
    var objClass = function(options){
        //判断el的异常值：el不存在、为空string、dom原生对象
        if(options.el){
            if(options.el instanceof jQuery&&options.el.length>0){
                this.$el = options.el;
            }else if(isDOM(options.el)){
                this.$el = $(options.el);
            }else if (typeof(options.el) == 'string'&&$(options.el).length>0) {
                this.$el = $(options.el);
            }
        }else{
            this.$el = $("<div></div>")             
        }
        this.options = options;
        eventTarget.call(this);
        helpersInit.call(this);
        render.call(this);
        eventInit.call(this);
        var _self = this;
        setTimeout(function(){
            _self.trigger('initEnd');
        }, 100);
    };
    var helpersInit = function(){
        hdbr.registerHelper('ifInDisabledValue', $.proxy(function(value, options) {
        	if(this.options.disabledValue){
        		var index = $.inArray(value, this.options.disabledValue.split(','));
            if (index >= 0){
//              return options.fn(this);
				return 'disabled=disabled class="disabled"';
            }else{
//              return options.inverse(this);
				return '';
            }
        	}
        },this));
        hdbr.registerHelper('ifInDefaultValue', $.proxy(function(value, options) {
            if (this.options.defaultValue){
            	var index = $.inArray(value, this.options.defaultValue.split(','));
            if (index >= 0){
//              return options.fn(this);
				return 'checked=checked class="checked"';
            }else{
//              return options.inverse(this);
				return '';
            }
            }
        },this));
    }
    var render = function(){
        var input = 'ul>li>div>input';
        var $input = $(input) ;  
//      var template = hdb.compile(tpl);
        this.$el.html(template(this.options));
        var $input = $(input,this.$el);
        if(this.options.disabled==1){
           this.disabled();
        }
    }
    var eventInit = function(){
        this.$el.on('click','.sn-checkboxes>ul>li>div',$.proxy(function(e){
            itemClick.call(this,e);
            this.trigger('itemClick',e);
        },this));
    }
    var initEnd = function(){};
    var itemClick = function(e){
        var $li = $(e.target || e.currentTarget).closest('li');
        var $inputs = $li.parents().find('input');
        var labels = $(this.$el).find('label');
        var $input = $li.find('input');
        var index = $li.index();
        var data = this.options.items[index];
        String.prototype.trim=function() {
            return this.replace(/(^\s*)|(\s*$)/g,'');
        }
        var str = $li[0].innerText.trim()
        if(str == "全选"){
        	if($input.attr('checked')){
        		num = $inputs.length;
        		for (var i=0,len=$inputs.length;i<len;i++) {
        			var $dv = $($inputs[i]).parent();
        			console.log($dv.attr('class'))
        			if(!$($inputs[i]).attr('disabled')){
        				$dv.removeAttr('class')
        				$($inputs[i]).attr('checked',false)
        				--num;
        			}
        		}
        		return false;
        	}else{
        		num = 0;
        		$input.attr('checked',true)
        		for (var i=0,len=$inputs.length;i<len;i++) {
        			var $dv = $($inputs[i]).parent();
        			if(!$($inputs[i]).attr('disabled')){
        				$dv.attr('class','checked')
						$($inputs[i]).attr('checked',true)
						++num;
        			}
        		}
        		--num;
        		return false;
        	}
        }
        
        if($input.attr('disabled')){
            return false;
        }
        if($input.attr('checked')){
            $input.attr('checked',false);
            $input.parent().removeClass('checked');
            --num;
        }else{
            $input.attr('checked',true);
            $input.parent().addClass('checked');
            if(num == 0){
            	for(var i=0,len=$inputs.length;i<len;i++){
		        	var $dv = $($inputs[i]).parent();
		        	if($dv[0].className == 'checked'){
		        		++num;
		        	}
	        	
	        	}
            }else{
            	++num;
            }
            
        }
        //需判断有没有全选项
        for(var j=0,len=labels.length;j<len;j++){
                var lab = labels[0].innerText.trim();
        		if(lab == '全选'){
        			if(($inputs.length-1) == num){
			        	for (var i=0,len=$inputs.length;i<len;i++) {
			        		var $dv = $($inputs[i]).parent();
			        		if(!$($inputs[i]).attr('disabled')){
			        			$dv.attr('class','checked');
			        			$($inputs[i]).attr('checked',true)
			        		}
			        	}
			        }else{
			        	for(var j=0,len=labels.length;j<len;j++){
                            var labb = labels[j].innerText.trim();
			        		if(labb == '全选'){
			        			if(!$($inputs[i]).attr('disabled')){
			        				$(labels[j]).siblings().removeClass()
			        				$(labels[j]).siblings().find('input').attr('checked',false)
			        			}
			        		}
			
			        	}
			        }
        		}

        }
        
        
        var itemData = {
            label:data.label,
            value:data.value,
            checked:$input.attr('checked')?1:0
        };
        this.trigger('change',e,itemData);
        if(data.click){
            data.click(e,itemData);
        }
    }
    $.extend(objClass.prototype,eventTarget.prototype,{
        version:VERSION,
        disabled:function(valueStr){
            var $container = $('ul>li>div', this.$el) ;
            var $input = null; 
            if(valueStr){
                var valueArr = valueStr.split(',');
                $.each(valueArr,function(key,value){
                    $input = $('input[value='+value+']',$container)
                    if(!($input.attr('disabled')=='disabled')){
                        $input.attr('disabled',true);
                        $input.parent().addClass('disabled');
                    }
                })
            }else{
                $input = $('input',$container);
                $input.attr('disabled',true);
                $('ul>li>div',this.$el).addClass('disabled');
            }
            
        },
        disable:function(data){
            this.disabled(data);
        },
        enable:function(){
            // var input = ;
            $('ul>li>div>input', this.$el).attr('disabled',false)
                .parent().removeClass('disabled');
        },
        get:function(){
            var $inputs = $('ul>li>div>input', this.$el) ; 
            // var input = 'ul>li>div>input';
            // var $input = $(input) ; 
            var data = [];
            $inputs.each(function(){
                if($(this).attr('checked')=='checked'){   
                    data.push($(this).val());
                }
            })
            return data.join(',');
        },
        set:function(data, e){
//          var $inputs = $('ul>li>div>input', this.$el) ;
            // var input = 'ul>li>div>input';
            // var $input = $(input) ; 
            data = data.split(',');
            var self = this;
            $.each(data,function(key,value){
                var $inputs = $('[value='+value+']',self.$el);
                if(!($inputs.attr('checked')=='checked')){
                    var index = $inputs.closest('li').index();
                    var itemData = {
                        label:self.options.items[index].label,
                        value:value,
                        checked:1
                    };
                    $inputs.attr('checked',true);
                    $inputs.parent().addClass('checked');
                    self.trigger('change',e,itemData);
                }
            })
        },
        clear:function(e){
            var $inputs = $('ul>li>div>input', this.$el) ;
            // var input = 'ul>li>div>input';
            // var $input = $(input) ; 
            var self = this;
            $inputs.each(function(){
                if($(this).attr('checked')=='checked'){
                    $(this).attr('checked',false);
                    $(this).parent().removeClass('checked');
                    var index = $(this).closest('li').index();
                    var data = self.options.items[index];
                    var itemData = {
                        label:data.label,
                        value:data.value,
                        checked:0
                    };
                    self.trigger('change',e,itemData);
                }
            })
        },
        checkAll:function(e){
            var self = this;
            var $inputs = $('ul>li>div>input', this.$el) ;
            // var input = 'ul>li>div>input';
            // var $input = $(input) ; 
            $inputs.each(function(){
                if(!($(this).attr('checked')=='checked')){
                    $(this).attr('checked',true);
                    $(this).parent().addClass('checked');
                    var index = $(this).closest('li').index();
                    var data = self.options.items[index];
                    var itemData = {
                        label:data.label,
                        value:data.value,
                        checked:1
                    };
                    self.trigger('change',e,itemData);
                }
            })
        },
        destroy:function(){
            this.$el.remove();
        }
    });
    //解决ie下console.log()报错问题
    window.console = window.console || (function(){
        var c = {};
        c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function(){};
        return c;
    })();
    // 判断是否为原生DOM
    var isDOM = function(obj){
        return obj.tagName ?true:false
    } 
    return objClass;
});

(function(c){var d=document,a='appendChild',i='styleSheet',s=d.createElement('style');s.type='text/css';d.getElementsByTagName('head')[0][a](s);s[i]?s[i].cssText=c:s[a](d.createTextNode(c));})
('@charset \"UTF-8\";\r\n\r\n.sn-checkboxes > .chk-list { margin: 0; padding: 0;  font-size: 12px;}\r\n.sn-checkboxes > .chk-list li { position: relative; display: inline-block; padding: 0 24px 12px 24px; list-style: none; }\r\n\r\n/* 全宽度竖向 */\r\n.sn-checkboxes.all-width > .chk-list li { display: block; }\r\n\r\n.sn-checkboxes > .chk-list li > div { position: absolute; top: -2px; left: 0;display: block; width: 20px; height: 20px; background: url() no-repeat; cursor: pointer; }\r\n.sn-checkboxes > .chk-list li > div > input,.chk-list li > div > ins { position: absolute; left: 10%; top: -20%; display: block; width: 120%; height: 120%; margin: 0; padding: 0; background: #FFF; opacity: 0; filter: alpha(opacity=0); box-sizing: border-box; padding: 0; outline: none; }\r\n.sn-checkboxes > .chk-list li > div, .chk-list li > div.static:hover { background-position: 0 0; }\r\n.sn-checkboxes > .chk-list li > div.hover, .chk-list li > div:hover { background-position: -20px 0; }\r\n.sn-checkboxes > .chk-list li > div.checked { background-position: -40px 0; }\r\n.sn-checkboxes > .chk-list li > div.disabled { background-position: -60px 0; cursor: default; }\r\n.sn-checkboxes > .chk-list li > div.checked.disabled { background-position: -80px 0; }\r\n.sn-checkboxes > .chk-list li > label { cursor: pointer; color: #333; }\r\n/* 高清屏支持 */\r\n@media only screen and (-webkit-min-device-pixel-ratio: 1.5),\r\n       only screen and (-moz-min-device-pixel-ratio: 1.5),\r\n       only screen and (-o-min-device-pixel-ratio: 3/2),\r\n       only screen and (min-device-pixel-ratio: 1.5) {\r\n    .sn-checkboxes > .chk-list li > div {\r\n        background-image: url();\r\n        -webkit-background-size: 100px 20px;\r\n        background-size: 100px 20px;\r\n    }\r\n}\r\n');
